#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char* longestCommonPrefix(char** strs, int strslen)
{
	int k = 1;
	int i = 0; char* arr = malloc(sizeof(char) *10*k ); 
	for (i = 0; i < strslen; i++)
	{
		int j = 0;
		if (i == 0)
		{
			while (*(*(strs + i) + j) != '\0' && *(*(strs + i+1) + j ) != '\0')
			{
				if (*(*(strs+i)+j) == *(*(strs+i+1)+j ))
				{
					arr[j] = *(*(strs+i)+j);
					j++;
				}
				else
				{
					break;
				}
			}
		}
		else
		{
			while (*(*(strs + i) + j) != '\0' && arr[j] != '\0')
			{
				if (*(*(strs + i) + j) == arr[j])
				{
					j++;
				}
				else
				{
					arr[j] = '\0';
					break;
				}
			}
		}
	}
	return arr;

}
int main()
{
	char* str[] = { "abcdtt","abcd","abcellk","abdr"};
	int len = sizeof(str) / sizeof(str[0]);
	char*arr=longestCommonPrefix(str, len);
	printf("%s", arr);
	free(arr);
	arr = NULL;
	return 0;
}